package us.mooresr.aircraftscheduling.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.aircraftscheduling.shared.model.Reservation;
import com.google.gwt.event.shared.HasHandlers;
import com.google.gwt.event.shared.HandlerRegistration;

public class ReservationChangedEvent extends
		GwtEvent<ReservationChangedEvent.ReservationChangedHandler> {

	public static Type<ReservationChangedHandler> TYPE = new Type<ReservationChangedHandler>();
	private Reservation reservation;

	public interface ReservationChangedHandler extends EventHandler {
		public void onReservationChanged(ReservationChangedEvent event);
	}

	public interface ReservationChangedHasHandlers extends HasHandlers {
		public HandlerRegistration addReservationChangedHandler(
				ReservationChangedHandler handler);
	}

	public ReservationChangedEvent(Reservation reservation) {
		this.reservation = reservation;
	}

	public Reservation getReservation() {
		return reservation;
	}

	@Override
	protected void dispatch(ReservationChangedHandler handler) {
		handler.onReservationChanged(this);
	}

	@Override
	public Type<ReservationChangedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<ReservationChangedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Reservation reservation) {
		source.fireEvent(new ReservationChangedEvent(reservation));
	}
}
